﻿#region Header
// ------------------------ Licence / Copyright ------------------------
// 
// ScrumTable for Scrum Meeting Support
// Copyright © HSR - Hochschule für Technik Rapperswil
// All Rights Reserved
// 
// Author:
//  Michael Gfeller Silvan Gehrig Patrick Boos
// 
// ---------------------------------------------------------------------
#endregion

#region Usings

using System;
using System.Linq;

using Microsoft.VisualStudio.TestTools.UnitTesting;

using ScrumTable.Common.Data;
using ScrumTable.DL.Data.Generic.Cache;

using WorkItemBucket = ScrumTable.DL.Data.Generic.Cache.CacheElementListEntryBucket<ScrumTable.DL.Data.Generic.Cache.CacheWorkItem>;
using WorkItemSavePair = ScrumTable.DL.Data.Generic.Cache.CacheSavePair<ScrumTable.DL.Data.Generic.Cache.CacheElementListEntryBucket<ScrumTable.DL.Data.Generic.Cache.CacheWorkItem>>;

#endregion

namespace ScrumTable.DL.Data.Generic.Test.Cache
{
    /// <summary>
    /// This is the test class for CacheReportTest class.
    /// </summary>
    [TestClass]
    public class CacheReportTest : CacheElementBaseTest<CacheReport>
    {
        #region Declarations
        //--------------------------------------------------------------------
        // Declarations
        //--------------------------------------------------------------------

        #endregion

        #region Properties
        //--------------------------------------------------------------------
        // Properties
        //--------------------------------------------------------------------

        private CacheProject Project { get; set; }

        #endregion

        #region Additional test attributes
        //
        // You can use the following additional attributes as you write your tests:
        //
        // Use ClassInitialize to run code before running the first test in the class
        // [ClassInitialize()]
        // public static void MyClassInitialize(TestContext testContext) { }
        //
        // Use ClassCleanup to run code after all tests in a class have run
        // [ClassCleanup()]
        // public static void MyClassCleanup() { }
        //
        // Use TestInitialize to run code before running each test 
        // [TestInitialize()]
        // public void MyTestInitialize() { }
        //
        // Use TestCleanup to run code after each test has run
        // [TestCleanup()]
        // public void MyTestCleanup() { }
        //
        #endregion

        #region Constructors / Destructor
        //--------------------------------------------------------------------
        // Constructors / Destructor
        //--------------------------------------------------------------------

        /// <summary>
        /// Creates a new CacheReportTest instance.
        /// </summary>
        public CacheReportTest()
        {
        }

        #endregion

        #region Methods
        //--------------------------------------------------------------------
        // Methods
        //--------------------------------------------------------------------

        /// <summary>
        /// Use TestInitialize to run code before running each test .
        /// </summary>
        [TestInitialize]
        public override void TestInitialize()
        {
            base.TestInitialize();

            Project = CacheContext.Projects.TryGetById(Resources.Project1.Id);
            ToTest = Project.Reports.First();
        }

        /// <summary>
        /// Use TestCleanup to run code after each test has run.
        /// </summary>
        [TestCleanup]
        public override void TestCleanup()
        {
            ToTest = null;
            base.TestCleanup();
        }

        [TestMethod]
        public void TestPath()
        {
            Assert.AreEqual("Report1", ToTest.Path);
        }

        [TestMethod]
        public void TestFullPath()
        {
            Assert.AreEqual(new Uri("Report1.jpg", UriKind.RelativeOrAbsolute), ToTest.FullPath);
        }

        [TestMethod]
        public void TestPostCommandArguments()
        {
            Assert.AreEqual(string.Empty, ToTest.PostCommandArguments);
        }

        [TestMethod]
        public void TestFieldDefinitions()
        {
            Assert.IsNotNull(ToTest.FieldDefinitions);
            Assert.AreEqual("Name", ToTest.FieldDefinitions.First().Name);
            Assert.AreEqual("Name Field", ToTest.FieldDefinitions.First().DisplayName);
            Assert.AreEqual(null, ToTest.FieldDefinitions.First().DefaultValue);
            Assert.AreEqual(typeof(string), ToTest.FieldDefinitions.First().FieldType);
            Assert.AreEqual(DataType.String, ToTest.FieldDefinitions.First().FieldTypeFormat);
        }

        #endregion

        #region Events
        //--------------------------------------------------------------------
        // Events
        //--------------------------------------------------------------------

        #endregion
    }
}
